﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
	<Style x:Key="ScrollBarStyle" TargetType="{x:Type ScrollBar}">
		<Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Template" Value="{DynamicResource ScrollBarControlTemplate}"/>
	</Style>
	<ControlTemplate x:Key="ScrollBarControlTemplate" TargetType="{x:Type ScrollBar}">
		<Grid x:Name="GridRoot" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
			<Grid.RowDefinitions>
				<RowDefinition MaxHeight="18"/>
				<RowDefinition Height="0.00001*"/>
				<RowDefinition MaxHeight="18"/>
			</Grid.RowDefinitions>
						
			<RepeatButton x:Name="DecreaseRepeat" Style="{DynamicResource RepeatButtonStyle}" Command="ScrollBar.LineUpCommand">
				<Grid>
					<Path x:Name="DecreaseArrow" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" Data="M 0 4 L 8 4 L 4 0 Z"/>
				</Grid>
			</RepeatButton>
						
			<!-- Track is a special layout container which sizes the thumb and the repeat button which do jump scrolling either side of it -->
			<Track Grid.Row="1" x:Name="PART_Track" Orientation="Vertical" IsDirectionReversed="true">
				<Track.Thumb>
					<Thumb Style="{DynamicResource ScrollBarThumbStyle}"/>
				</Track.Thumb>
				<Track.IncreaseRepeatButton>
					<RepeatButton x:Name="PageUp" Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="ScrollBar.PageDownCommand"/>
				</Track.IncreaseRepeatButton>
				<Track.DecreaseRepeatButton>
					<RepeatButton x:Name="PageDown" Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="ScrollBar.PageUpCommand"/>
				</Track.DecreaseRepeatButton>
			</Track>
						
			<RepeatButton Grid.Row="2" x:Name="IncreaseRepeat" Style="{DynamicResource RepeatButtonStyle}" Command="ScrollBar.LineDownCommand">
				<Grid>
					<Path x:Name="IncreaseArrow" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" Data="M 0 0 L 4 4 L 8 0 Z"/>
				</Grid>
			</RepeatButton>
		</Grid>
					
		<!-- This uses a single template for ScrollBar and rotate it to be Horizontal
					It also changes the commands so that the it does Left and Right instead of Up and Down Commands -->
		<ControlTemplate.Triggers>
			<Trigger Property="Orientation" Value="Horizontal">

				<!-- Rotate the ScrollBar from Vertical to Horizontal -->
				<Setter Property="LayoutTransform" TargetName="GridRoot">
					<Setter.Value>
						<RotateTransform Angle="-90"/>
					</Setter.Value>
				</Setter>
							
				<!-- Track is bound to Orientation internally, so we need to rotate it back to Vertical -->
				<Setter TargetName="PART_Track" Property="Orientation" Value="Vertical"/>
					
				<!-- Change the commands to do Horizontal commands -->
				<Setter Property="Command" Value="ScrollBar.LineLeftCommand" TargetName="DecreaseRepeat"/>
				<Setter Property="Command" Value="ScrollBar.LineRightCommand" TargetName="IncreaseRepeat"/>
				<Setter Property="Command" Value="ScrollBar.PageLeftCommand" TargetName="PageDown"/>
				<Setter Property="Command" Value="ScrollBar.PageRightCommand" TargetName="PageUp"/>
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>
	<Style x:Key="RepeatButtonStyle" d:IsControlPart="True" TargetType="{x:Type RepeatButton}" BasedOn="{x:Null}">
		<Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
		<Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<Grid>
						<Border x:Name="Border" BorderThickness="{DynamicResource ThicknessSize_1}" Background="{DynamicResource BrushControlBackgroundLight}" BorderBrush="{DynamicResource ImpassiveColor4}" CornerRadius="{DynamicResource CornerRadiusSmall}"/>
						<ContentPresenter HorizontalAlignment="Center" x:Name="ContentPresenter" VerticalAlignment="Center" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="true">
							<Setter Property="Background" TargetName="Border" Value="{DynamicResource BrushControlBackgroundLightFocused}"/>
						</Trigger>
						<Trigger Property="IsPressed" Value="true">
							<Setter Property="BorderBrush" TargetName="Border" Value="{DynamicResource ImpassiveColor4}"/>
							<Setter Property="Background" TargetName="Border" Value="{DynamicResource BrushControlBackgroundLightPressed}"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
							<Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
							<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style x:Key="ScrollBarThumbStyle" d:IsControlPart="True" TargetType="{x:Type Thumb}" BasedOn="{x:Null}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Grid Margin="0,0,0,0" x:Name="Grid">
						<Rectangle HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="3" RadiusY="3" Fill="{DynamicResource BrushControlBackgroundLight}" Stroke="{DynamicResource ImpassiveColor4}"/>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="Fill" TargetName="Rectangle" Value="{DynamicResource BrushControlBackgroundLightFocused}"/>
						</Trigger>
						<Trigger Property="IsDragging" Value="True">
							<Setter Property="Fill" TargetName="Rectangle" Value="{DynamicResource BrushControlBackgroundLightPressed}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<!-- Resource dictionary entries should be defined here. -->
	
	<!-- Simple Repeat Button - This is used by Simple ScrollBar for the up and down buttons -->
	
</ResourceDictionary>